package com.xuanyuanxinyu.func.workmanager

import android.content.Context
import android.util.Log
import androidx.work.Worker
import androidx.work.WorkerParameters

class SleepWorker(context : Context,parameters : WorkerParameters) : Worker(context,parameters) {
    override fun doWork() : Result {
        // 重复执行10次
        repeat(10) {
            // Sleep on a background thread.
            val sleepDuration = inputData.getLong(SLEEP_DURATION,1000)
            Thread.sleep(sleepDuration)
            Log.d("1111","休眠$sleepDuration")
        }
        
        return Result.success()
    }
    
    companion object {
        const val SLEEP_DURATION = "SLEEP_DURATION"
    }
}



